/*
 * Laser.cpp
 *
 *  Created on: Nov 19, 2012
 *      Author: ryan2
 */

#include <iostream>
#include "Laser.h"
#include "SpaceTrader.h"

Laser::Laser(int x, int y, int yVel, const std::string image) : bounds(SDL_Rect()), xVel(10), yVel(yVel), icon(NULL), isDestroyed(false) {

	icon = load_image(image+".png",false);

	bounds.x = x;
	bounds.y = y;
	bounds.w = icon->w;
	bounds.h = icon->h;

}

Laser::Laser(int x, int y, int xVel, int yVel, const std::string image) : bounds(SDL_Rect()), xVel(xVel), yVel(yVel), icon(NULL), isDestroyed(false) {
    
	icon = load_image(image+".png",false);
    
	bounds.x = x;
	bounds.y = y;
	bounds.w = icon->w;
	bounds.h = icon->h;
    
}

void Laser::move() {

    if (bounds.x < SCREEN_WIDTH){
        bounds.x += xVel;
    }
    if (bounds.y < SCREEN_HEIGHT){
        bounds.y += yVel;
    }
}


int Laser::getX() {
	return bounds.x;
}

int Laser::getY() {
	return bounds.y;
}

int Laser::getW() {
	return bounds.w;
}

void Laser::destroy(){
    isDestroyed = true;
}

SDL_Rect Laser::getBounds(){
    return bounds;
}

void Laser::show(SDL_Surface *screen)
{
	if (!isDestroyed) apply_surface( bounds.x, bounds.y, icon, screen);
}
